NOTE
1.32 InnoDB undo log
The undo log records logical data changes with inverse operations for inserts, updates, and deletes. These notes explain its relationship to transactions.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is undo log
- A log of the MySQL InnoDB storage engine.
- Mainly records logical changes to data.
- An
INSERTstatement corresponds to aDELETEundo log. - An
UPDATEstatement corresponds to an undo log containing the inverseUPDATE. - A
DELETEstatement corresponds to anINSERTundo log.
- An
- Before actually inserting, deleting, or modifying a record, the corresponding undo log needs to be recorded first.
2. Why undo log Is Needed
2.1. Implement Atomicity
- If a crash occurs halfway through a transaction, after restart the incomplete modifications need to be undone. This requires the undo log.
2.2. Implement MVCC
3. undo log Implementation
3.1. Deletion Timing
- When no transaction needs these rollback logs anymore, the rollback logs are deleted. Therefore, try not to use long transactions.
4. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub